<template>
  <div class="app-container">
    <el-form label-width="85px" inline  class="demo-form-inline">
            <el-form-item label="商户名称">
                <el-input v-model="queryParams.user" clearable placeholder="请输入商户名称"></el-input>
            </el-form-item>
            <el-form-item label="帐号类型">
                <el-select v-model="queryParams.region1" clearable placeholder="请选择账号类型">
                    <el-option label="全部" value="shanghai"></el-option>
                    <el-option label="区域一" value="shanghai"></el-option>
                    <el-option label="区域二" value="beijing"></el-option>
                </el-select>
            </el-form-item>
            <el-form-item>
                <el-button type="primary" @click="queryObj">查询</el-button>
                <el-button type="success" @click="newObj">新建</el-button>
            </el-form-item>
    </el-form>
    <page-table ref="table" index :fetch="getTableList" :query="queryParams">
      <el-table-column align="center" min-width="120" label="商户名称" prop="col1"  show-overflow-tooltip/>
      <el-table-column align="center" min-width="120" label="关联活动数量" prop="col2"  show-overflow-tooltip/>
      <el-table-column align="center" min-width="120" label="商户状态" prop="col3"  show-overflow-tooltip/>
      <el-table-column align="center" min-width="120" label="最后编辑人" prop="col5" show-overflow-tooltip/>
      <el-table-column align="center" min-width="180" label="创建时间" prop="col5" show-overflow-tooltip/>
      <el-table-column align="center" min-width="200" label="操作" >
        <template slot-scope="{row}">
          <el-button type="text" @click="templateObj(row)">可用模板</el-button>
          <el-button type="text" @click="detailsObj(row)">查看详情</el-button>
          <el-button type="text" @click="editObj(row)">编辑</el-button>
          <el-button type="text" @click="stopObj(row)">停用</el-button>
         </template>
      </el-table-column>
    </page-table>
  </div>
</template>

<script>
import { getExamplePageList } from '@/api/document'
export default {
  data () {
    return {
      queryParams: {},
      query: false,
      dialogTitle: '',
      params: {},
      rules: {
        arg1: { required: true, max: 8, message: '请输入名称,最多8个字', trigger: 'blur' },
        arg2: { required: true, message: '请输入客户去向', trigger: 'blur' },
        arg6: { required: true, message: '请输入联系方式', trigger: 'blur' }
      }
    }
  },
  methods: {
    getTableList (query) {
      return getExamplePageList(query)
    },
    refreshTable () {
      this.$refs.table.refresh()
    },
    fromObj () {
      this.$router.push({ path: 'AccountList_form' })
    },
    deleteObj (row) {
      var _this = this
      this.confirmBox({
        title: '确认删除账号',
        message: '账号' + '“' + row.col1 + '”' + '删除后，该账号将无法登陆，且不可恢复，确认删除后立即生效。',
        okText: '确认删除',
        callback (action, instance) {
          // 方法内使用js写法
          if (action === 'confirm') {
            _this.messageBox({
              message: '该账号已删除！'
            })
            _this.refreshTable()
          } else if (action === 'cancel') {
          }
        }
      })
    },
    getParams () {
      return this.params
    },
    newObj () {
      this.$router.push({ path: 'BusinessesList_new', query: { title: '新建商户' } })
    },
    editObj (row) {
      this.$router.push({ path: 'BusinessesList_edit', query: { title: '编辑商户', id: '1' } })
    },
    submitOk (params) {
      // 回调的是提交时候的完整参数
    },
    submitClose () {
      this.params = {}
    },
    templateObj () {
      //    可用模板
    },
    detailsObj () {
      //    查看详情
    },
    stopObj (row) {
      var _this = this
      //    var title = ''
      //    var message = ''
      //    var backMessage = ''
      //    var activeStr = ''
      //    if (row.activeStr === '停用') {
      //      title = '确认停用账号'
      //      message = '账号' + row.col1 + '停用后，该账号将无法登陆，确认停用后立即生效。'
      //      backMessage = '该账号已停用！'
      //      activeStr = '停用'
      //    } else if (row.activeStr === '启用') {
      //      title = '确认启用账号'
      //      message = '账号' + row.col1 + '启用后，该账号将恢复使用，确认启动后立即生效。'
      //      backMessage = '该账号已启用！'
      //      activeStr = '启用'
      //    }
      this.confirmBox({
        title: '确认停用商户',
        message: '商户' + '“' + row.col1 + '”' + '停用后，商户将不能添加任何活动，且该商户所有活动将立即暂停，确认停用后立即生效。请再三确认！',
        okText: '确认停用',
        callback (action, instance) {
          // 方法内使用js写法
          if (action === 'confirm') {
            _this.messageBox({
              message: '该商户已停用！'
            })
            _this.refreshTable()
          } else if (action === 'cancel') {
          }
        }
      })
    },
    queryObj () {
      this.query = this.queryed(this.queryParams)
      this.refreshTable()
    }
  }
}
</script>

<style scoped lang="scss">

</style>
